<template>
  <div>
    <Login ref="refLogin" v-if="!isLogin" @loginSuccess="isLogin = true" />
    <UserInfo v-else ref="refUserInfo" />
  </div>
</template>

<script>
import UserSessionService from "@/service/UserSessionService"
import Login from "@/components/user/Login.vue"
import UserInfo from "@/components/user/UserInfo.vue"

export default {
  name: 'User',
  components: {Login, UserInfo},
  data() {
    return {
      isLogin: false
    }
  },
  methods: {
    loading() {
      UserSessionService.getToken(token => {
        if (token) {
          this.isLogin = true
        }
      })
    }
  },
  mounted() {
    this.loading()
  }
}
</script>

<style scoped>

</style>